﻿using System.Drawing;
using System.Xml.Serialization;

namespace RPG1
{
    [XmlInclude(typeof(Magician))]
    [XmlInclude(typeof(Minotaur))]
    [XmlInclude(typeof(Necromancer))]
    [XmlInclude(typeof(Warrior))]
    public class Role
    {
        private int id;
        private string name;
        private int originalLife; // 原始生命值
        private int currentLife; // 当前生命值 
        private int damage;  // 力量
        private int agile; // 敏捷
        private int brains; // 智力
        private int speed; // 速度
        private Point currentLocation; // 原始位置
        private Point originaLocation;//  当前位置
        private Weapon wpn;

        public Role()
        {
        }

        protected Role(int id, string name, int originalLife, int currentLife, int damage, int agile, int brains, int speed, Point currentLocation, Point originaLocation, Weapon wpn)
        {
            this.id = id;
            this.name = name;
            this.originalLife = originalLife;
            this.currentLife = currentLife;
            this.damage = damage;
            this.agile = agile;
            this.brains = brains;
            this.speed = speed;
            this.currentLocation = currentLocation;
            this.originaLocation = originaLocation;
            this.wpn = wpn;
        }

        public int Id { get => id; set => id = value; }
        public string Name { get => name; set => name = value; }
        public int OriginalLife { get => originalLife; set => originalLife = value; }
        public int CurrentLife { get => currentLife; set => currentLife = value; }
        public int Damage { get => damage; set => damage = value; }
        public int Agile { get => agile; set => agile = value; }
        public int Brains { get => brains; set => brains = value; }
        public int Speed { get => speed; set => speed = value; }
        public Point CurrentLocation { get => currentLocation; set => currentLocation = value; }
        public Point OriginaLocation { get => originaLocation; set => originaLocation = value; }
        public Weapon Wpn { get => wpn; set => wpn = value; }

        public virtual int getAttack()
        {
            return 0;
        }
        public virtual int getDefense()
        {
            return 0;
        }
        public override string ToString()
        {
            string s= "{ID: " + Id +
                        ", name:" + Name +
                        ", 原始生命值:" + OriginalLife +
                        ", 当前生命值:" + CurrentLife +
                        ", 力量:" + Damage +
                        ", 敏捷:" + Agile +
                        ", 智力:" + Brains +
                        ", 速度:" + Speed +
                        ", 原始位置:" + CurrentLocation +
                        ", 当前位置:" + OriginaLocation;
            if (Wpn != null)
                s += ", 武器:" + Wpn.ToString();
            s += "}";
            return s;

        }
    }
}
